﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hyt.Core.Security;
using Hyt.Core.Data;
using System.ComponentModel;

namespace Hyt.Passport.Models
{
    [DefaultOrderby("DepartmentId")]
    public class Administrator : Principal
    {
        public Administrator() : base()
        {
            this.SetPrincipalType("Administrator");
        }

        [Description("用户名")]
        public string UserName { get; set; }

        [Description("密码")]
        public string Password { get; set; }

        [Description("姓名")]
        public string Name { get; set; }

        public DateTime? ThisLoginDateTime { get; set; }
        public DateTime? LastLoginDateTime { get; set; }
        public string ThisLoginIp { get; set; }
        public string LastLoginIp { get; set; }
        public int LoginTimes { get; set; }
        public Guid? PositionId { get; set; }
        public Guid? DepartmentId { get; set; }
        public PassportStatus State { get; set; }

        public virtual Position Position { get; set; }
        public virtual Department Department { get; set; }

        public override List<IPrincipal> GetParents()
        {
            var parents=new List<IPrincipal>();
            if (Position != null)
            {
                parents.Add(Position); 
            }
            if (Department != null)
            {
                parents.Add(Department);
            }
            return parents;
        }
    }
}
